package com.test.spring.mybatis.service;

import com.test.spring.mybatis.dao.FoodTypeDAO;
import com.test.spring.mybatis.pojo.FoodType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 徒有琴
 */

@Service
public class FoodTypeService {

    @Autowired//根据类型自动注入
    private FoodTypeDAO foodTypeDAO;
    @Value("${jdbc.url}")
    private String url;
    public void add() throws Exception {
        System.out.println(url);
        try {
            foodTypeDAO.addType("奶茶5");
            foodTypeDAO.addType("奶茶6");
            //throw new Exception("异常");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public List<FoodType> getFood(){
        return foodTypeDAO.getTypes();
    }

//    public void setFoodTypeDAO(FoodTypeDAO foodTypeDAO) {
//        this.foodTypeDAO = foodTypeDAO;
//    }
}
